package com.txw.javaCore.server.common;

import com.txw.javaCore.api.enums.DataDictEnum;
import com.txw.javaCore.model.mapper.DataDictMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

/**
 * @PROJECT_NAME: JavaCoreB2
 * @DESCRIPTION: 系统在启动成功后初始化相应的数据（初始化服务）
 * @Author: 涂玄武
 * @DATE: 2020/12/21 9:54
 */
@Component
public class SystemDataInit implements CommandLineRunner {

    private static final Logger log= LoggerFactory.getLogger(SystemDataInit.class);

    @Autowired
    private DataDictMapper dictMapper;

    //初始化的代码逻辑
    @Override
    public void run(String... strings) throws Exception {
        log.info("--系统数据初始化服务开始--");

        initAppDataDict();
    }

    public void initAppDataDict(){
        SystemDataConfig.putAppDataDictOs(dictMapper.selectByType(DataDictEnum.AppOsType.getCode()));
        SystemDataConfig.putAppDataDictDevice(dictMapper.selectByType(DataDictEnum.AppDeviceType.getCode()));
    }
}
